﻿using System;

namespace Functions
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 1;
            int b = 2;

            //int c = a + b;
            int c = Add(a, b);
            int max1 = Max(a, b);

            int x = 5;
            int y = 7;

            //int z = x + y;
            int z = Add(x, y);
            int max2 = Max(x, y);

            int[] array = new int[] { 1, 2, 3, 4, 5 };

            int sumOfArrayElements = Sum(array);
            int max3 = Max(array);
        }

        static int Add(int value1, int value2)
        {
            return value1 + value2;
        }

        static int Sum(int[] values)
        {
            int sum = 0;

            for (int i = 0; i < values.Length; i++)
            {
                sum += values[i];
            }

            return sum;
        }

        static int Max(int a, int b)
        {
            if(a > b)
            {
                return a;
            }

            return b;
        }

        static int Max(int[] values)
        {
            int max = values[0];

            for (int i = 1; i < values.Length; i++)
            {
                /*
                if(values[i] > max)
                {
                    max = values[i];
                }
                */

                max = Max(max, values[i]);
            }

            return max;
        }
    }
}
